<!-- HTML header for doxygen 1.8.14-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="cache-control" content="max-age=86400"/>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>GBDK 2020 Docs: gbdk-lib/include/gb/bcd.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen_extra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">GBDK 2020 Docs
   &#160;<span id="projectnumber">4.4.0</span>
   </div>
   <div id="projectbrief">API Documentation for GBDK 2020</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('gb_2bcd_8h.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">bcd.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;types.h&gt;</code><br />
<code>#include &lt;<a class="el" href="stdint_8h_source.html">stdint.h</a>&gt;</code><br />
</div>
<p><a href="gb_2bcd_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a5b336fcb3fc84fe505dc7e14d0ec17a7"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#a5b336fcb3fc84fe505dc7e14d0ec17a7">BCD_HEX</a>(v)&#160;&#160;&#160;((<a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a>)(v))</td></tr>
<tr class="separator:a5b336fcb3fc84fe505dc7e14d0ec17a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8a3023920aa103a74c7d59007bcc7b6f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#a8a3023920aa103a74c7d59007bcc7b6f">MAKE_BCD</a>(v)&#160;&#160;&#160;<a class="el" href="sms_2bcd_8h.html#a5b336fcb3fc84fe505dc7e14d0ec17a7">BCD_HEX</a>(0x ## v)</td></tr>
<tr class="separator:a8a3023920aa103a74c7d59007bcc7b6f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a4813acd7f1852dd32b67175ca6aca2eb"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="stdint_8h.html#a33594304e786b158f3fb30289278f5af">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a></td></tr>
<tr class="separator:a4813acd7f1852dd32b67175ca6aca2eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:af3d125e9dbb48d630cf7e2f7d1343ba1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#af3d125e9dbb48d630cf7e2f7d1343ba1">uint2bcd</a> (<a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a> i, <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *value) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:af3d125e9dbb48d630cf7e2f7d1343ba1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0b14c76afa669863ed43c080f5baca98"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#a0b14c76afa669863ed43c080f5baca98">bcd_add</a> (<a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *sour, const <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *value) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:a0b14c76afa669863ed43c080f5baca98"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a743275b2ee21c93633a933a2d3073d4e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#a743275b2ee21c93633a933a2d3073d4e">bcd_sub</a> (<a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *sour, const <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *value) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:a743275b2ee21c93633a933a2d3073d4e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aec09ce7373727160488408c65fc8a91e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="gb_2bcd_8h.html#aec09ce7373727160488408c65fc8a91e">bcd2text</a> (const <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *bcd, <a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> tile_offset, <a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *buffer) <a class="el" href="asm_2types_8h.html#a0971918860055db2e50dacea4da8f3bc">OLDCALL</a></td></tr>
<tr class="separator:aec09ce7373727160488408c65fc8a91e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Support for working with BCD (Binary Coded Decimal)</p>
<p>See the example BCD project for additional details. </p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a5b336fcb3fc84fe505dc7e14d0ec17a7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5b336fcb3fc84fe505dc7e14d0ec17a7">&#9670;&nbsp;</a></span>BCD_HEX</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BCD_HEX</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">v</td><td>)</td>
          <td>&#160;&#160;&#160;((<a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a>)(v))</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="a8a3023920aa103a74c7d59007bcc7b6f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8a3023920aa103a74c7d59007bcc7b6f">&#9670;&nbsp;</a></span>MAKE_BCD</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MAKE_BCD</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">v</td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="sms_2bcd_8h.html#a5b336fcb3fc84fe505dc7e14d0ec17a7">BCD_HEX</a>(0x ## v)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Converts an integer value into BCD format</p>
<p>A maximum of 8 digits may be used </p>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="a4813acd7f1852dd32b67175ca6aca2eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4813acd7f1852dd32b67175ca6aca2eb">&#9670;&nbsp;</a></span>BCD</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef <a class="el" href="stdint_8h.html#a33594304e786b158f3fb30289278f5af">uint32_t</a> <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="af3d125e9dbb48d630cf7e2f7d1343ba1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af3d125e9dbb48d630cf7e2f7d1343ba1">&#9670;&nbsp;</a></span>uint2bcd()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void uint2bcd </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="stdint_8h.html#adf4d876453337156dde61095e1f20223">uint16_t</a>&#160;</td>
          <td class="paramname"><em>i</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Converts integer <b>i</b> into BCD format (Binary Coded Decimal) </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">i</td><td>Numeric value to convert </td></tr>
    <tr><td class="paramname">value</td><td>Pointer to a BCD variable to store the converted result </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a0b14c76afa669863ed43c080f5baca98"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0b14c76afa669863ed43c080f5baca98">&#9670;&nbsp;</a></span>bcd_add()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void bcd_add </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *&#160;</td>
          <td class="paramname"><em>sour</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Adds two numbers in BCD format: <b>sour</b> += <b>value</b> </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sour</td><td>Pointer to a BCD value to add to (and where the result is stored) </td></tr>
    <tr><td class="paramname">value</td><td>Pointer to the BCD value to add to <b>sour</b> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a743275b2ee21c93633a933a2d3073d4e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a743275b2ee21c93633a933a2d3073d4e">&#9670;&nbsp;</a></span>bcd_sub()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void bcd_sub </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *&#160;</td>
          <td class="paramname"><em>sour</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Subtracts two numbers in BCD format: <b>sour</b> -= <b>value</b> </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sour</td><td>Pointer to a BCD value to subtract from (and where the result is stored) </td></tr>
    <tr><td class="paramname">value</td><td>Pointer to the BCD value to subtract from <b>sour</b> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aec09ce7373727160488408c65fc8a91e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aec09ce7373727160488408c65fc8a91e">&#9670;&nbsp;</a></span>bcd2text()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> bcd2text </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="gb_2bcd_8h.html#a4813acd7f1852dd32b67175ca6aca2eb">BCD</a> *&#160;</td>
          <td class="paramname"><em>bcd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a>&#160;</td>
          <td class="paramname"><em>tile_offset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="stdint_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *&#160;</td>
          <td class="paramname"><em>buffer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Convert a BCD number into an asciiz (null terminated) string and return the length </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">bcd</td><td>Pointer to BCD value to convert </td></tr>
    <tr><td class="paramname">tile_offset</td><td>Optional per-character offset value to add (use 0 for none) </td></tr>
    <tr><td class="paramname">buffer</td><td>Buffer to store the result in</td></tr>
  </table>
  </dd>
</dl>
<p>Returns: Length in characters (always 8)</p>
<p><b>buffer</b> should be large enough to store the converted string (9 bytes: 8 characters + 1 for terminator)</p>
<p>There are a couple different ways to use <b>tile_offset</b>. For example: </p><ul>
<li>It can be the Index of the Font Tile '0' in VRAM to allow the buffer to be used directly with <a class="el" href="nes_8h.html#a6ab3fa75195d44d8d7e867d4a4cb1131">set_bkg_tiles</a>. </li>
<li>It can also be set to the ascii value for character '0' so that the buffer is a normal string that can be passed to <a class="el" href="stdio_8h.html#a133c04c35a1c14c6f8d8078831705661">printf</a>. </li>
</ul>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.14-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
</div>
</body>
</html>
